package com.tanhua.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册拦截器
        registry.addInterceptor(tokenInterceptor)
                //拦截范围：/**
                .addPathPatterns("/**")
                //不拦截范围：这两个请求路径，是登录前访问的，还没有生成token值，允许不允许token
                .excludePathPatterns("/user/login", "/user/loginVerification");
    }
}